<?php

namespace Home\Controller;
use Think\Controller;
use Think\Db;

class EvaluateController extends Controller{
    private $companyid;
    public $ddd;
    public function __construct()
    {
        parent::__construct();
        $this->companyid = M('config')->field('companyid')->find();
    }

    public function createEvaluate(){
           $data = I();
           if (IS_POST){
               if (empty($data['orderid'])){
                   datamsg(0,'缺少订单号');
               }
               if(empty($data['servicescore'])){
                   datamsg(0,'请评价本次服务');
               }
               $where['orderid'] = $data['orderid'];
               $phone = M('xllog')->where($where)->field('mobile,openid')->find();
               $data['companyid'] = $this->companyid;
               $data['userphone'] = $phone['mobile'];
               $data['driveropenid'] = $phone['openid'];
               $data['evaluatetime'] = time();
               $evaluate = M('evaluates');
               $ise = $evaluate->where($where)->find();
               if ($ise){
                   echo '订单已经评价，请勿重复操作';
               }
               $res = $evaluate->add($data);
               if ($res){
                   $save['isevaluate'] = 1;
                   M('xllog')->where($where)->save($save);
                   datamsg(1,'评价成功');
               }else{
                   datamsg(0,'评价失败请重试');
               }
           }$this->assign('orderid',$data['orderid']);
            $this->display('createevaluate');



   }



   //调用投诉接口
    public function sendComplaint(){

    }

}